package in.muton.edushare.pages.common;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.pages.EduShareBasePage;

import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.edushare.common.orm.ORMInterface;
import com.edushare.common.vo.Users;

public class EdusharePanel extends Panel {

	private static final long serialVersionUID = 7546165994497383659L;

	public EdusharePanel(String id, EduShareBasePage page) {
		super(id);
		basePage = page;
	}

	public EdusharePanel(String id, IModel<?>model, EduShareBasePage page){
		super(id,model);
		basePage = page;
	}

	public EdusharePanel(String id) {
		super(id);
		basePage = null;
	}

	public EdusharePanel(String id, IModel<?>model){
		super(id,model);
		basePage = null;
	}	
	
	public void setError(String error){
		if(basePage != null)
			basePage.setErrorMessage(error);
	}
	
	public void clearError(){
		if(basePage != null)
			basePage.clearError();
	}
	
	public void setPage(EduShareBasePage page){
		this.basePage = page;
	}
	
	public EduShareBasePage getBasePage(){
		return basePage;
	}
	
	public ORMInterface getORMInterface(){
		return ((EduShareSession)getSession()).getSessionORMInterface();
	}
	
	public Users getLoggedInUser(){
		return EduShareSession.get().getLoggedInUser();
	}
	
	protected EduShareBasePage basePage = null;
}
